﻿using Microsoft.TeamFoundation.Client;
using TFS.Kanban.VS2010.Constants;

namespace TFS.Kanban.VS2010.Services
{
    public class ProjectCollectionService : IProjectCollectionService
    {
        private TfsTeamProjectCollection _projectCollection;
        
        public TfsTeamProjectCollection GetProjectCollection()
        {
            if (_projectCollection == null)
            {
                _projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(Location.Uri, new UICredentialsProvider());
                _projectCollection.EnsureAuthenticated();
            }

            return _projectCollection;
        }
    }
}